<%@ taglib prefix="sql_rt" uri="http://java.sun.com/jstl/sql_rt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/jsp/includeCss.jsp" %>
<%@ include file="/WEB-INF/jsp/includeJs.jsp" %>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp" %>


<table width="100%" border="0" cellpadding="0" cellspacing="5">
	<tr>
		<td valign="top">
			<table class="dbborder" width="100%" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td valign="bottom" class="blueTableBg">&nbsp;计划详情</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<div class="globalText" style="padding: 15px;border: solid 1px #999999;width: 768px;margin-left: 15px;margin-bottom: 20px;" >
	<table class="globalText dbborder" width="100%" border="0" cellpadding="5" cellspacing="5" style="margin: 5px;">
		<tr>
			<td width="20%">计划名称</td>
			<td>
				${plan.name}
			</td>
		</tr>
		<tr>
			<td>计划日期</td>
			<td>
				${plan.planDate}
			</td>
		</tr>
		<tr>
			<td>计划状态</td>
			<td>
				<c:choose>
                    <c:when test="${plan.status=='new'}">未审核</c:when>
                    <c:when test="${plan.status=='deny'}">
                        退回</td></tr>
                        <tr>
                            <td>退回原因</td>
                            <td>${plan.denyNotes}</td>
                        </tr>
                    </c:when>
                    <c:when test="${plan.status=='confirm'}">已审核</c:when>
                    <c:when test="${plan.status=='change'}">
                        已变更</td></tr>
                        <tr>
                            <td>变更原因</td>
                            <td>${plan.changeNotes}</td>
                        </tr></c:when>
				</c:choose>
				<%--<c:if test="${plan.status=='deny'}">--%>
					<%--(<font style="color: red;" >${plan.denyNotes}</font>)--%>
				<%--</c:if>--%>
			</td>
		</tr>
<!-- 		<tr> -->
<!-- 			<td colspan="2" ><input style="margin-left: 150px;" onclick="window.history.back();" type="button" class=" btnStyle" value="返回" /></td> -->
<!-- 		</tr> -->
	</table>

</div>

<table class="dbborder" width="70%" border="0" cellpadding="0" cellspacing="1">
	<tr class="rowHead">
		<td height="20" nowrap align="center" class="globalTextBold">任务名称</td>
		<td height="20" nowrap align="center" class="globalTextBold">终端信息</td>
		<td height="20" nowrap align="center" class="globalTextBold">项目信息</td>
		<td height="20" nowrap align="center" class="globalTextBold">开始时间</td>
		<td height="20" nowrap align="center" class="globalTextBold">截止时间</td>
		<td height="20" nowrap align="center" class="globalTextBold">任务状态</td>
	</tr>
	<c:forEach var="planProject" items="${plan.planProjects}" varStatus="status">
		<c:forEach var="planJob" items="${planProject.planJobs}" varStatus="status">
			<tr class="rowClass">
				<td height="20" class="globalText">${planJob.job.name}</td>
				<td height="20" class="globalText">${planJob.storeName}</td>
				<td height="20" class="globalText">${planProject.projectName}</td>
				<td height="20" class="globalText">${planJob.startTime}</td>
				<td height="20" class="globalText">${planJob.endTime}</td>
				<td height="20" class="globalText">${planProject.plan.status}</td>
			</tr>
		</c:forEach>
	</c:forEach>
</table>

<c:if test="${statusEdit=='true'}">
	<form target="tempFrame" id="planStatusForm" action="<c:url value="/plan/planStatusEdit.html"></c:url>" method="post">
		<div class="globalText" style="padding: 15px;border: solid 1px #999999;width: 768px;margin-left: 15px;margin-top: 50px;" >
			<div style="display: none;" id="denyReason" align="center" class="globalText">
				<span style="vertical-align: top;">退回原因:</span>
				<textarea id="denyNotes" name="denyNotes" class="globalText required" rows="6" cols="80"></textarea>
			</div>
			<div style="margin-top: 10px;" align="center">
				<input onclick="statusConfirm();" type="button" class="btnStyle" value="审核通过" />
				<input id="denyBtn" onclick="statusDeny();" style="margin-left: 50px;" type="button" class="btnStyle" value="审核退回" />
			</div>
		</div>
		<input type="hidden" name="planId" value="${plan.id}" />
		<input type="hidden" name="status" id="statusValue" />
		<input type="hidden" name="planVersion" id="planVersion" value="${plan.version}" />
	</form>


	<script>
		function statusDeny(){
			if(!$("#denyReason").is(":visible")){
				$("#denyBtn").val("确认审核退回");
				$("#denyReason").show("blind", {}, 200,null);
				return;
			}
			$("#statusValue").val("deny");
			doSubmit();
		}

		function statusConfirm(){
			if($("#denyReason").is(":visible")){
				$("#denyBtn").val("审核退回");
				$("#denyReason").hide("blind", {}, 200,function(){
					$("#statusValue").val("confirm");
					doSubmit();
				});
			}else{
				$("#statusValue").val("confirm");
				doSubmit();
			}

		}

		function doSubmit(){
			if($("#planStatusForm").valid() && confirm("确认审核操作?")){
				$("#planStatusForm").submit();
			}
		}

		$().ready(function() {
			var validate=$("#planStatusForm").validate({
				showErrors: customShowErrors,
				onfocusout:false,
				onkeyup:false,
				onclick:false
			});
		});

		function submitCallbackSuccess(obj){
			window.location="<c:url value="/plan/planList.html"></c:url>?planId=${plan.id}&from=subordinate";
		}
	</script>
</c:if>

